package com.cx.controller;

import com.cx.service.HotelMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class AllHotel {
    @Autowired
    HotelMapperService hotelMapperService;
    @ResponseBody
    @RequestMapping("allHotel")
    public List<com.cx.dto.AllHotel> allHotel(String [] locate, String[] brand, String[] price, String[] service, Integer pageNum,String condition) {
//        if(null == pageNum){
//            pageNum = 1;
//        }
//        for(String s : locate){
//            System.out.println(s);
//        }
//        if(condition.equals("默认排序")){
//
//        }
        boolean priceflag = false;
        boolean scoreflag = false;
        if (condition.equals("价格")){
            priceflag = true;
        }
        if (condition.equals("评分")){
            scoreflag = true;
        }
        System.out.println(priceflag + "=="  +scoreflag);
        int count = hotelMapperService.count(locate, brand, price, service, pageNum,priceflag,scoreflag);

        List<com.cx.dto.AllHotel> allHotels =  hotelMapperService.findHotelByCondition(locate, brand, price, service, pageNum,priceflag,scoreflag);
        if(allHotels.size() != 0){
            allHotels.get(0).setCount(count);
        }
        return allHotels;
    }

}
